/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.net.greenet.policybank.logic;

import cn.net.greenet.common.policy_service.PolicySupport;
import java.util.List;

import com.ambimmort.prserver.bean.RepositoryOperationLogBean;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 获取每类策略类型某一个策略仓库的所有最新策略
 *
 * @author liangdelin
 */
public class GetNewPolicy {

    public String getNewPolicyList(String type, String instance, int pageCount, int page) {
        //getHeadPoliciesWithLog(String type, String instance, int pageCount, int page)

        List<RepositoryOperationLogBean> logBeans = PolicySupport.getInstance().getApi().getHeadPoliciesWithLog(type, instance, pageCount, page);
        JSONArray jsona = new JSONArray();
        for (RepositoryOperationLogBean logBean : logBeans) {
            JSONObject jo = new JSONObject();
            jo.put("id", logBean.getId());
            jo.put("CreateTime", logBean.getCreateTime());
            jo.put("MessageNo", logBean.getSvnFile().getMessageNo());
            jo.put("Content", logBean.getSvnFile().getContent());  //这里需要解析UC
            jsona.add(jo);
        }
        return jsona.toString();

    }

}
